﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using KeaoBase;
using System.Xml;

namespace KeaoDataService
{
    public partial class HunNingTuSheZhi : Form
    {
        public HunNingTuSheZhi()
        {
            InitializeComponent();
        }

        private void HunNingTuSheZhi_Load(object sender, EventArgs e)
        {
            XmlNode hunNingTuNode = KeaoUtils.ConfigGetNodeListByTag("混凝土")[0];
            XmlNode shaShiLiao = hunNingTuNode.SelectNodes("沙石料")[0];
            cmb_shashiliao_1.SelectedItem = shaShiLiao.ChildNodes[0].Attributes["类型"].Value;
            cmb_shashiliao_2.SelectedItem = shaShiLiao.ChildNodes[1].Attributes["类型"].Value;
            cmb_shashiliao_3.SelectedItem = shaShiLiao.ChildNodes[2].Attributes["类型"].Value;
            cmb_shashiliao_4.SelectedItem = shaShiLiao.ChildNodes[3].Attributes["类型"].Value;
            cmb_shashiliao_5.SelectedItem = shaShiLiao.ChildNodes[4].Attributes["类型"].Value;
            cmb_shashiliao_6.SelectedItem = shaShiLiao.ChildNodes[5].Attributes["类型"].Value;
            cmb_shashiliao_7.SelectedItem = shaShiLiao.ChildNodes[6].Attributes["类型"].Value;
            cmb_shashiliao_8.SelectedItem = shaShiLiao.ChildNodes[7].Attributes["类型"].Value;
            chk_shashiliao_1.Checked = shaShiLiao.ChildNodes[0].Attributes["状态"].Value == "启用" ? true : false;
            chk_shashiliao_2.Checked = shaShiLiao.ChildNodes[1].Attributes["状态"].Value == "启用" ? true : false;
            chk_shashiliao_3.Checked = shaShiLiao.ChildNodes[2].Attributes["状态"].Value == "启用" ? true : false;
            chk_shashiliao_4.Checked = shaShiLiao.ChildNodes[3].Attributes["状态"].Value == "启用" ? true : false;
            chk_shashiliao_5.Checked = shaShiLiao.ChildNodes[4].Attributes["状态"].Value == "启用" ? true : false;
            chk_shashiliao_6.Checked = shaShiLiao.ChildNodes[5].Attributes["状态"].Value == "启用" ? true : false;
            chk_shashiliao_7.Checked = shaShiLiao.ChildNodes[6].Attributes["状态"].Value == "启用" ? true : false;
            chk_shashiliao_8.Checked = shaShiLiao.ChildNodes[7].Attributes["状态"].Value == "启用" ? true : false;
            XmlNode fenLiao = hunNingTuNode.SelectNodes("粉料")[0];
            cmb_fenliao_1.SelectedItem = fenLiao.ChildNodes[0].Attributes["类型"].Value;
            cmb_fenliao_2.SelectedItem = fenLiao.ChildNodes[1].Attributes["类型"].Value;
            cmb_fenliao_3.SelectedItem = fenLiao.ChildNodes[2].Attributes["类型"].Value;
            cmb_fenliao_4.SelectedItem = fenLiao.ChildNodes[3].Attributes["类型"].Value;
            cmb_fenliao_5.SelectedItem = fenLiao.ChildNodes[4].Attributes["类型"].Value;
            cmb_fenliao_6.SelectedItem = fenLiao.ChildNodes[5].Attributes["类型"].Value;
            cmb_fenliao_7.SelectedItem = fenLiao.ChildNodes[6].Attributes["类型"].Value;
            cmb_fenliao_8.SelectedItem = fenLiao.ChildNodes[7].Attributes["类型"].Value;
            chk_fenliao_1.Checked = fenLiao.ChildNodes[0].Attributes["状态"].Value == "启用" ? true : false;
            chk_fenliao_2.Checked = fenLiao.ChildNodes[1].Attributes["状态"].Value == "启用" ? true : false;
            chk_fenliao_3.Checked = fenLiao.ChildNodes[2].Attributes["状态"].Value == "启用" ? true : false;
            chk_fenliao_4.Checked = fenLiao.ChildNodes[3].Attributes["状态"].Value == "启用" ? true : false;
            chk_fenliao_5.Checked = fenLiao.ChildNodes[4].Attributes["状态"].Value == "启用" ? true : false;
            chk_fenliao_6.Checked = fenLiao.ChildNodes[5].Attributes["状态"].Value == "启用" ? true : false;
            chk_fenliao_7.Checked = fenLiao.ChildNodes[6].Attributes["状态"].Value == "启用" ? true : false;
            chk_fenliao_8.Checked = fenLiao.ChildNodes[7].Attributes["状态"].Value == "启用" ? true : false;
            XmlNode wanJiaJi = hunNingTuNode.SelectNodes("外加剂")[0];
            cmb_waijiaji_1.SelectedItem = wanJiaJi.ChildNodes[0].Attributes["类型"].Value;
            cmb_waijiaji_2.SelectedItem = wanJiaJi.ChildNodes[1].Attributes["类型"].Value;
            cmb_waijiaji_3.SelectedItem = wanJiaJi.ChildNodes[2].Attributes["类型"].Value;
            cmb_waijiaji_4.SelectedItem = wanJiaJi.ChildNodes[3].Attributes["类型"].Value;
            cmb_waijiaji_5.SelectedItem = wanJiaJi.ChildNodes[4].Attributes["类型"].Value;
            chk_waijiaji_1.Checked = wanJiaJi.ChildNodes[0].Attributes["状态"].Value == "启用" ? true : false;
            chk_waijiaji_2.Checked = wanJiaJi.ChildNodes[1].Attributes["状态"].Value == "启用" ? true : false;
            chk_waijiaji_3.Checked = wanJiaJi.ChildNodes[2].Attributes["状态"].Value == "启用" ? true : false;
            chk_waijiaji_4.Checked = wanJiaJi.ChildNodes[3].Attributes["状态"].Value == "启用" ? true : false;
            chk_waijiaji_5.Checked = wanJiaJi.ChildNodes[4].Attributes["状态"].Value == "启用" ? true : false;
            XmlNode shui = hunNingTuNode.SelectNodes("水")[0];
            cmb_shui_1.SelectedItem = shui.ChildNodes[0].Attributes["类型"].Value;
            cmb_shui_2.SelectedItem = shui.ChildNodes[1].Attributes["类型"].Value;
            chk_shui_1.Checked = shui.ChildNodes[0].Attributes["状态"].Value == "启用" ? true : false;
            chk_shui_2.Checked = shui.ChildNodes[1].Attributes["状态"].Value == "启用" ? true : false;

        }

        private void menu_btn_shezhi_Click(object sender, EventArgs e)
        {
            KeaoUtils.ConfigSetNodeAttr("沙石料1", "类型", cmb_shashiliao_1.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料2", "类型", cmb_shashiliao_2.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料3", "类型", cmb_shashiliao_3.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料4", "类型", cmb_shashiliao_4.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料5", "类型", cmb_shashiliao_5.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料6", "类型", cmb_shashiliao_6.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料7", "类型", cmb_shashiliao_7.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料8", "类型", cmb_shashiliao_8.Text);
            KeaoUtils.ConfigSetNodeAttr("沙石料1", "状态", chk_shashiliao_1.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("沙石料2", "状态", chk_shashiliao_2.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("沙石料3", "状态", chk_shashiliao_3.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("沙石料4", "状态", chk_shashiliao_4.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("沙石料5", "状态", chk_shashiliao_5.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("沙石料6", "状态", chk_shashiliao_6.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("沙石料7", "状态", chk_shashiliao_7.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("沙石料8", "状态", chk_shashiliao_8.Checked ? "启用" : "禁用");

            KeaoUtils.ConfigSetNodeAttr("粉料1", "类型", cmb_fenliao_1.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料2", "类型", cmb_fenliao_2.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料3", "类型", cmb_fenliao_3.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料4", "类型", cmb_fenliao_4.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料5", "类型", cmb_fenliao_5.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料6", "类型", cmb_fenliao_6.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料7", "类型", cmb_fenliao_7.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料8", "类型", cmb_fenliao_8.Text);
            KeaoUtils.ConfigSetNodeAttr("粉料1", "状态", chk_fenliao_1.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("粉料2", "状态", chk_fenliao_2.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("粉料3", "状态", chk_fenliao_3.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("粉料4", "状态", chk_fenliao_4.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("粉料5", "状态", chk_fenliao_5.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("粉料6", "状态", chk_fenliao_6.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("粉料7", "状态", chk_fenliao_7.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("粉料8", "状态", chk_fenliao_8.Checked ? "启用" : "禁用");

            KeaoUtils.ConfigSetNodeAttr("外加剂1", "类型", cmb_waijiaji_1.Text);
            KeaoUtils.ConfigSetNodeAttr("外加剂2", "类型", cmb_waijiaji_2.Text);
            KeaoUtils.ConfigSetNodeAttr("外加剂3", "类型", cmb_waijiaji_3.Text);
            KeaoUtils.ConfigSetNodeAttr("外加剂4", "类型", cmb_waijiaji_4.Text);
            KeaoUtils.ConfigSetNodeAttr("外加剂5", "类型", cmb_waijiaji_5.Text);
            KeaoUtils.ConfigSetNodeAttr("外加剂1", "状态", chk_waijiaji_1.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("外加剂2", "状态", chk_waijiaji_2.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("外加剂3", "状态", chk_waijiaji_3.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("外加剂4", "状态", chk_waijiaji_4.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("外加剂5", "状态", chk_waijiaji_5.Checked ? "启用" : "禁用");

            KeaoUtils.ConfigSetNodeAttr("水1", "类型", cmb_shui_1.Text);
            KeaoUtils.ConfigSetNodeAttr("水2", "类型", cmb_shui_2.Text);
            KeaoUtils.ConfigSetNodeAttr("水1", "状态", chk_shui_1.Checked ? "启用" : "禁用");
            KeaoUtils.ConfigSetNodeAttr("水2", "状态", chk_shui_2.Checked ? "启用" : "禁用");

            KeaoUtils.ShowInfoMessage("信息保存成功。");
            DialogResult = DialogResult.OK;

        }

    }
}
